package com.apexsoft.assets.base.request;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * Created by Administrator on 2018/2/23.
 */
@ApiModel(description = "认证请求报文")
public class AuthRequest {
    @ApiModelProperty(position = 1, notes = "终端ID")
    @NotEmpty(message = "终端ID不能为空")
    private String clientId;

    @ApiModelProperty(position = 2, notes = "签名串:将[user=${用户名}&password=${密码}&ext=${扩展数据}&amp;timestamp=${当前时间戳}]用appSecret作为KEY，采用AES加密所得值")
    @NotEmpty(message = "签名串不能为空")
    private String signature;

    @ApiModelProperty(position = 3, notes = "扩展数据，JSON格式，存储appVersion，channel，resolution")
    private String ext;

    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }

    public String getExt() {
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }
    @ApiModelProperty(hidden = true)
    public JSONObject getExtJSON() {
        if (ext != null) {
            try {
                return (JSONObject) JSONObject.parse(ext);
            } catch (Exception e) {
                return new JSONObject();
            }
        } else {
            return new JSONObject();
        }
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }
}
